// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_pr.p_activity.p_view;

import android.content.*;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.*;
import com.nnee.p_g.cls_b;
import com.nnee.p_img.cls_c;
import com.nnee.p_pr.p_activity.cls_PRISActivitySetting;
import com.nnee.p_pr.p_c.cls_a;
import java.io.File;
import java.util.*;

// Referenced classes of package com.nnee.p_pr.p_activity.view:
//            z, v, y, m, 
//            x, aa, u, bt

public class cls_AdView extends cls_FrameLayout
{

    public AdView(Context context)
    {
        super(context);
        e = false;
        f = false;
        g = false;
        h = false;
        i = true;
        j = 0;
        k = 0;
        r = new cls_z(this);
        s = 1;
        t = new cls_v(this);
        a(context);
    }

    public AdView(Context context, AttributeSet attributeset)
    {
        super(context, attributeset);
        e = false;
        f = false;
        g = false;
        h = false;
        i = true;
        j = 0;
        k = 0;
        r = new cls_z(this);
        s = 1;
        t = new cls_v(this);
        a(context);
    }

    static int a(AdView adview, int i1)
    {
        adview.j = i1;
        return i1;
    }

    private Bitmap a(Uri uri)
    {
        return BitmapFactory.decodeFile(uri.getPath());
    }

    static ViewFlipper a(AdView adview)
    {
        return adview.q;
    }

    private void a(long l1)
    {
        a(((bt) (new cls_y(this))), l1);
    }

    private void a(Context context)
    {
        o = context;
    }

    static void a(AdView adview, long l1)
    {
        adview.a(l1);
    }

    static void a(AdView adview, List list, ImageView imageview, int i1)
    {
        adview.a(list, imageview, i1);
    }

    private void a(List list)
    {
        m = list;
    }

    private void a(List list, ImageView imageview, int i1)
    {
        if(list != null && list.size() != 0)
        {
            if(i1 >= list.size())
                i1 %= list.size();
            imageview.setImageBitmap(a(((m)list.get(i1)).a));
            imageview.setTag(list.get(i1));
        }
    }

    static boolean a(AdView adview, boolean flag)
    {
        adview.i = flag;
        return flag;
    }

    static ImageView b(AdView adview)
    {
        return adview.p;
    }

    static Context c(AdView adview)
    {
        return adview.o;
    }

    static int d(AdView adview)
    {
        return adview.j;
    }

    static int e(AdView adview)
    {
        return adview.k;
    }

    static void f(AdView adview)
    {
        adview.h();
    }

    private void g()
    {
        p.setOnClickListener(new cls_x(this));
    }

    static void g(AdView adview)
    {
        adview.j();
    }

    static List h(AdView adview)
    {
        return adview.i();
    }

    private void h()
    {
        if(!d() && f() > 0)
        {
            SharedPreferences sharedpreferences = o.getSharedPreferences("ad_pref", 0);
            j = sharedpreferences.getInt("key_curpos", 0);
            k = sharedpreferences.getInt("key_curindex", 0);
            a((List)l.get(j), k);
            q.setVisibility(0);
            p.setVisibility(0);
        }
    }

    private List i()
    {
        return m;
    }

    static boolean i(AdView adview)
    {
        return adview.f;
    }

    static int j(AdView adview)
    {
        int i1 = adview.k;
        adview.k = i1 + 1;
        return i1;
    }

    private void j()
    {
        boolean flag;
        List list;
        android.os.Message message;
        if(g && h && i)
            flag = true;
        else
            flag = false;
        if(flag == f) goto _L2; else goto _L1
_L1:
        list = i();
        if(!flag || list == null || list.size() <= 0) goto _L4; else goto _L3
_L3:
        message = t.obtainMessage(1);
        if(k < list.size()) goto _L6; else goto _L5
_L5:
        if(l != null && l.size() > 0)
        {
            j = 1 + j;
            if(j >= l.size())
                j = j % l.size();
            a((List)l.get(j), 0);
            com.nnee.p_g.cls_b.b("AdViewFlipper", (new StringBuilder()).append("updateRunning:onLoad(mAdList.get(").append(j).append("), 0)").toString());
        }
_L2:
        return;
_L6:
        t.sendMessageDelayed(message, ((m)list.get(k)).b);
_L7:
        f = flag;
        if(true) goto _L2; else goto _L4
_L4:
        t.removeMessages(1);
          goto _L7
    }

    static List k(AdView adview)
    {
        return adview.l;
    }

    static int l(AdView adview)
    {
        int i1 = adview.j;
        adview.j = i1 + 1;
        return i1;
    }

    public void a()
    {
        long l1 = cls_PRISActivitySetting.n(o);
        long l2 = System.currentTimeMillis() - l1;
        if(l2 >= 0x493e0L)
            h();
        else
            a(0x493e0L - l2);
    }

    public void a(bt bt, long l1)
    {
        if(n == null)
            n = new cls_adBroadcast(o);
        n.a(bt, l1);
    }

    public void a(List list, int i1)
    {
        StringBuilder stringbuilder = (new StringBuilder()).append("onLoad:list.size()=");
        Object obj;
        if(list == null)
            obj = "null";
        else
            obj = Integer.valueOf(list.size());
        com.nnee.p_g.cls_b.b("AdViewFlipper", stringbuilder.append(obj).append(" firstIndex=").append(i1).toString());
        if(list != null && list.size() != 0)
        {
            if(i1 < 0)
                i1 = 0;
            if(i1 >= list.size())
                i1 = -1 + list.size();
            q.removeAllViews();
            for(int j1 = 0; j1 < 2; j1++)
            {
                ImageView imageview = new ImageView(o);
                imageview.setScaleType(android.widget.ImageView.ScaleType.CENTER_CROP);
                android.widget.FrameLayout.LayoutParams layoutparams = new android.widget.FrameLayout.LayoutParams(-1, com.nnee.p_img.cls_c.a(o, 40F));
                q.addView(imageview, j1, layoutparams);
                a(list, imageview, i1 + j1);
                imageview.setOnClickListener(new cls_aa(this));
            }

            Animation animation = AnimationUtils.loadAnimation(o, 0x7f04000b);
            animation.setAnimationListener(new cls_u(this));
            q.setInAnimation(animation);
            q.setOutAnimation(AnimationUtils.loadAnimation(o, 0x7f04000c));
            e = true;
            h = true;
            f = false;
            a(list);
            k = i1;
            j();
        }
    }

    public void b()
    {
        o = null;
        if(n != null)
        {
            n.a();
            n = null;
        }
        c();
    }

    public void c()
    {
        h = false;
        e = false;
        h = false;
        j();
        if(q != null)
        {
            q.clearAnimation();
            q.removeAllViews();
        }
        if(l != null)
        {
            for(Iterator iterator = l.iterator(); iterator.hasNext(); ((List)iterator.next()).clear());
        }
        m = null;
    }

    public boolean d()
    {
        return e;
    }

    /**
     * @deprecated Method e is deprecated
     */

    public void e()
    {
        this;
        JVM INSTR monitorenter ;
        if(n != null)
            n.a();
        this;
        JVM INSTR monitorexit ;
        return;
        Exception exception;
        exception;
        throw exception;
    }

    public int f()
    {
        if(l == null)
            l = new ArrayList();
        l.clear();
        for(int i1 = 0; i1 < 10; i1++)
        {
            File file = new File(com.nnee.p_pr.p_c.cls_a.a());
            if(!file.exists())
                continue;
            File afile[] = file.listFiles();
            if(afile == null || afile.length <= 0)
                continue;
            ArrayList arraylist = new ArrayList();
            arraylist.clear();
            int j1 = afile.length;
            for(int k1 = 0; k1 < j1; k1++)
            {
                cls_m m1 = new cls_m();
                m1.a = Uri.fromFile(afile[k1]);
                m1.b = 2000 * (k1 + 1) + i1 * 500;
                arraylist.add(m1);
            }

            l.add(arraylist);
        }

        return l.size();
    }

    protected void onAttachedToWindow()
    {
        super.onAttachedToWindow();
        IntentFilter intentfilter = new IntentFilter();
        intentfilter.addAction("android.intent.action.SCREEN_OFF");
        intentfilter.addAction("android.intent.action.USER_PRESENT");
        getContext().registerReceiver(r, intentfilter);
        g();
        a();
    }

    protected void onDetachedFromWindow()
    {
        super.onDetachedFromWindow();
        g = false;
        getContext().unregisterReceiver(r);
        j();
        b();
    }

    protected void onWindowVisibilityChanged(int i1)
    {
        super.onWindowVisibilityChanged(i1);
        boolean flag;
        if(i1 == 0)
            flag = true;
        else
            flag = false;
        g = flag;
        j();
    }

    public static final long a = 0x493e0L;
    private static final String b = "AdViewFlipper";
    private static final int c = 2;
    private static final float d = 40F;
    private boolean e;
    private boolean f;
    private boolean g;
    private boolean h;
    private boolean i;
    private int j;
    private int k;
    private List l;
    private List m;
    private AdBroadcast n;
    private Context o;
    private ImageView p;
    private ViewFlipper q;
    private final BroadcastReceiver r;
    private final int s;
    private final Handler t;

    private class cls_AdBroadcast extends BroadcastReceiver
    {

        /**
         * @deprecated Method a is deprecated
         */

        public void a()
        {
            this;
            JVM INSTR monitorenter ;
            h = null;
            if(d)
            {
                e.unregisterReceiver(this);
                d = false;
            }
            a(g);
            this;
            JVM INSTR monitorexit ;
            return;
            Exception exception;
            exception;
            throw exception;
        }

        /**
         * @deprecated Method a is deprecated
         */

        void a(PendingIntent pendingintent)
        {
            this;
            JVM INSTR monitorenter ;
            f.cancel(pendingintent);
            this;
            JVM INSTR monitorexit ;
            return;
            Exception exception;
            exception;
            throw exception;
        }

        /**
         * @deprecated Method a is deprecated
         */

        void a(PendingIntent pendingintent, long l1)
        {
            this;
            JVM INSTR monitorenter ;
            long l2 = l1 + SystemClock.elapsedRealtime();
            f.set(2, l2, pendingintent);
            this;
            JVM INSTR monitorexit ;
            return;
            Exception exception;
            exception;
            throw exception;
        }

        /**
         * @deprecated Method a is deprecated
         */

        public void a(bt bt1, long l1)
        {
            this;
            JVM INSTR monitorenter ;
            a(g);
            Uri uri = ContentUris.withAppendedId(b, 0L);
            Intent intent = (new Intent("com.android.im.intent.action.HEARTBEAT")).setDataAndType(uri, "vnd.android.im/heartbeat");
            g = PendingIntent.getBroadcast(e, 0, intent, 0);
            if(!d)
            {
                e.registerReceiver(this, IntentFilter.create("com.android.im.intent.action.HEARTBEAT", "vnd.android.im/heartbeat"));
                d = true;
            }
            h = bt1;
            a(g, l1);
            this;
            JVM INSTR monitorexit ;
            return;
            Exception exception;
            exception;
            throw exception;
        }

        public void onReceive(Context context, Intent intent)
        {
            if(h != null)
                h.a();
        }

        private static final String a = "com.android.im.intent.action.HEARTBEAT";
        private static final Uri b = Uri.parse("content://im/heartbeat");
        private static final String c = "vnd.android.im/heartbeat";
        private static boolean d = false;
        private final Context e;
        private final AlarmManager f;
        private PendingIntent g;
        private bt h;


        public AdBroadcast(Context context)
        {
            e = context;
            f = (AlarmManager)context.getSystemService("alarm");
        }
    }

}
